package com.yikome.product.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.yikome.common.CommonRepository;
import com.yikome.product.entity.ProductSku;

@Repository
public interface ProductSkuRepository extends CommonRepository<ProductSku, Long> {

    @Query("select ps from ProductSku ps where ps.yn = 1 and ps.productId = :productId")
    List<ProductSku> findByProductId(@Param("productId") Long productId);

    void deleteByProductId(Long productId);

    @Query("select p from ProductSku p where p.productId = :productId and p.yn = 1")
    List<ProductSku> findAllByProductId(@Param("productId") Long productId);

    @Query("select p from ProductSku p where p.yn = 1 and p.barcode = :barcode")
    ProductSku findByBarcode(@Param("barcode") String barcode);
}
